from selenium.webdriver.common.by import By
from base.base_page import BasePage
from config import HOME_URL


class HomePage(BasePage):
    def __init__(self):
        super().__init__()
        self.login_loc = (By.LINK_TEXT, "登录")
        self.search_loc = (By.ID, "q")
        self.search_btn_loc = (By.CLASS_NAME, "ecsc-search-button")

    def open_home_page(self):
        self.get_url(HOME_URL)

    def go_login(self):
        self.click_el(self.login_loc)

    def search_goods(self, goods_name):
        self.input_content(self.search_loc, goods_name)
        self.click_el(self.search_btn_loc)


